//
//  UserViewController.m
//  暴走段子_王桂敏
//
//  Created by 王桂敏 on 15/6/6.
//  Copyright (c) 2015年 lanouhn. All rights reserved.
//

#import "UserViewController.h"
#import "UserModel.h"
#import "NetWorkEngine.h"
#import "UserView.h"
#import "Define.h"
@interface UserViewController ()<NetworkEngineDelegate>
@property (nonatomic,retain) UserView *userView;
@end

@implementation UserViewController
- (void)dealloc{
    [_user_id release];
    [_userView release];
    [super dealloc];
}

- (UserView *)userView{
    if (!_userView) {
        self.userView = [[[UserView alloc] initWithFrame:CGRectMake(0, 0, kSCREENWIDTH, kSCREENHEIGHT)] autorelease];
        [self.view addSubview:_userView];
    }
    return _userView;
}


- (id)initWithUser_id:(NSString *)user_id{
    self = [super init];
    if (self) {
        self.user_id = user_id;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];

//    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:135 / 256.0 green:206 / 256.0 blue:250 / 256.0 alpha:1];

    self.view.backgroundColor = [UIColor whiteColor];
    NSString *user_idStr = [NSString stringWithFormat:@"%@",self.user_id];
    NetWorkEngine *engine = [NetWorkEngine engineWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://nearby.qiushibaike.com/user/%@/detail?AdID=1432645618379894600906",user_idStr]] parameters:nil delegate:self];
    [engine start];

}


- (void)networkDidFinishLoading:(NetWorkEngine *)engine withInfo:(id)info{
    NSDictionary *data = [NSJSONSerialization JSONObjectWithData:info options:NSJSONReadingMutableContainers error:nil];
    NSDictionary *userData = data[@"userdata"];
    UserModel *user = [[[UserModel alloc] initWithDictionary:userData] autorelease];

    
    [self.userView _configUserWithUser:user];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
